<!DOCTYPE html>
<html class="no-js css-menubar" lang="zh-cn">
  <head>
    <title>弹窗子页面</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <!-- 360浏览器默认使用Webkit内核 -->
    <meta name="renderer" content="webkit" />
   
    <!-- 第3方lib引入 -->
    <script type="text/javascript" src="../lib/include-lib.js?time=20210803" libpath="../lib/" include="jquery,haoutil"></script>

    <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=UgxnvZqij9D9YSFiD9dpY4KSQ0InBHVV"></script>
    <style type="text/css">
      body,
      html {
        width: 100%;
        height: 100%;
        margin: 0;
        font-family: "微软雅黑";
      }
      #streetscapeMap {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>

  <body>
    <div id="streetscapeMap"></div>
   
    <!--页面js-->
    <script>
      var panorama;
      var panoramaService;

      $(document).ready(function () {
        var request = haoutil.system.getRequest();
        console.log(request.lng, request.lat)
        
        var baiduMpt = new BMap.Point(request.lng, request.lat);

        var map = new BMap.Map("streetscapeMap");
        map.centerAndZoom(baiduMpt, 15);
        map.addTileLayer(new BMap.PanoramaCoverageLayer());

        panorama = new BMap.Panorama("streetscapeMap");
        
        panoramaService = new BMap.PanoramaService(); 
        panoramaService.getPanoramaByLocation(new BMap.Point(request.lng, request.lat), function(data){
            var panoramaInfo="";  
            if (data == null) {  
                alert('此位置无数据') 
                return;  
            }  
            panorama.setPosition(new BMap.Point(request.lng, request.lat)); //根据经纬度坐标展示全景图
        })
        panorama.setPov({ heading: -40, pitch: 6 });

        panorama.addEventListener("position_changed", function (e) { 
          //街景图位置改变后，三维地图中心点也随之改变
          var pos = panorama.getPosition(); 
          if (parent) {
            pos = parent.mars3d.PointTrans.bd2wgs([pos.lng, pos.lat]);//转为无偏坐标
            parent.updateMarker({ lng: pos[0], lat: pos[1] });//传到三维地图做更新
          }
        });

      });

      //外部传入坐标，更新街景
      function setPosition(point) {
        let bdPoint = parent.mars3d.PointTrans.wgs2bd([point.lng, point.lat]); //转为偏移坐标
        panoramaService.getPanoramaByLocation(new BMap.Point(bdPoint[0], bdPoint[1]), function(data){
            var panoramaInfo="";  
            if (data == null) {  
                alert('此位置无数据') 
                return;  
            }  
            panorama.setPosition(new BMap.Point(bdPoint[0], bdPoint[1])); //根据经纬度坐标展示全景图
        })
      }
    </script>
  </body>
</html>